<?php
class Req_sfsGame {
	const url = "http://127.0.0.1:38899";
	static function http_post_data($url, $data_string) {
		$ch = curl_init ( $url );
		curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
		curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data_string );
		curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
		curl_setopt ( $ch, CURLOPT_TIMEOUT, 5 );
		curl_setopt ( $ch, CURLOPT_HTTPHEADER, array (
				'Content-Type: application/json',
				'Content-Length: ' . strlen ( $data_string ) 
		) );
		$data = curl_exec ( $ch );
		return $data;
	}
	/**
	 *
	 * 设置游戏难度
	 *
	 * @param unknown $level        	
	 * @return mixed
	 */
	function SetLevel($url, $level) {
		$url = Req_sfsGame::url . $url . "/lobbyHandler";
		$arr = array (
				'req' => '1',
				'level' => $level 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsGame::http_post_data ( $url, $json_string );
	}
}
